<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <input type="text" placeholder="姓名" v-model="name">
    <input type="text" placeholder="工资" v-model="salary">
    <input type="text" placeholder="工作" v-model="job">
    <input type="button" value="添加" @click="f()">
    <table border="1">
    <caption>员工列表</caption>
     <tr>
         <th>编号</th>
         <th>姓名</th>
         <th>工资</th>
         <th>工作岗位</th>
         <th>操作</th>
     </tr>
       <tr v-for="(person,i) in arr">
           <td>{{i+1}}</td>
           <td>{{person.name}}</td>
           <td>{{person.salary}}</td>
           <td>{{person.job}}</td>
        <td>  <input type="button" value="删除 " @click="del(i)"></td>
       </tr>
    </table>
<script src="../js/vue.js"></script>
<script>
      let v = new Vue({
          el:"div",
          data:{
              name:"",
              salary:"",
              job:"",
              arr:[{name:"张三",salary:500,job:"销售"},
                  {name:"李四",salary: 300,job:"人事"}

              ]
          },methods:{
              f(){
                //往arr 数组中添加一个对象
                  v.arr.push({name:v.name,salary:v.salary,job:v.job})
                  v.name="";
                  v.salary = "";
                  v.job = "";
              },
              del(i){
                  //删除arr数组中i下标位置对应的对象
                  v.arr.splice(i,1);
                  v.arr.splice()
              }
          }

      })

</script>
</div>
</body>
</html>